/* eslint valid-jsdoc: "off" */

'use strict';

const path = require("path");

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1562810187401_2902';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    cluster:{
      listen: {
        path: '',
        port: 7788,
        hostname: '',
      }
    },
    mongoose:{
      client: {
        url: 'mongodb://47.98.136.221:27017/biaodan',
        options: {
          useNewUrlParser:true,
          useFindAndModify:false,
          useCreateIndex:true
        },
      }
    },
    view :{
      root: [
        path.join(appInfo.baseDir, 'app/view'),
        //path.join(appInfo.baseDir, 'path/to/another')// 其他的模板地址
      ].join(','),
      mapping:{
        '.ejs': 'ejs' // .nj 结尾的文件，使用 nunjucks引擎
      },
      defaultViewEngine: 'ejs' //默认使用nunjucks
    },
    logger :{
      level: 'DEBUG',
      consoleLevel: 'DEBUG'
    },
    security:{
      csrf:{
        enable: false, // 前后端分离，post请求不方便携带_csrf
        ignoreJSON: true
      },
      domainWhiteList: [ '*' ]
    },
    cors:{
      // enable: true,
      origin: '*',
      allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
     // credentials: true, // 允许跨域请求携带cookies
    },
    multipart:{
      mode: 'file'
    },
    bodyParser: { //文件和数据限制
      jsonLimit: '10mb',
      formLimit: '10mb',
    }
  };
  return {
    ...config,
    ...userConfig,
  };
};
